<template>
  <div class="generalize">
    <div v-if="!$store.state.isbusNewsDitle">
      <ul class="news_list">
        <li
          class="news_item"
          v-for="item in sonList"
          :key="item.id"
        >
          <div
            @click="handDitle(item)"
            class="title_name pointer"
          >
            {{item.title}}
          </div>
          <div class="ditle_title_box">
            <span class="ditle_title">作者: </span>
            <span class="ditle_title title_mar">{{item.author}}</span>
            <span class="ditle_title">发布时间: </span>
            <span class="ditle_title title_mar">{{item.createdTime}}</span>
            <span class="ditle_title">点击率：</span>
            <span class="ditle_title">{{'50'}}次</span>
          </div>
          <img
            class="ditle_off"
            src="../../../assets/imges/zhixian.png"
            alt=""
          >

        </li>
      </ul>
      <div class="page_box">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :page-sizes="[5,10,15]"
          :page-size="pageBid3.limit"
          layout="total, prev, pager, next, jumper"
          :total="pageBid3.totalCount"
        >
        </el-pagination>
        <!-- <router-view></router-view> -->
      </div>
    </div>
    <transition name="fade">
      <div
        v-if="$store.state.isbusNewsDitle"
        class="busDitle_dog"
      >
        <mydetails
          :sonList="sonList"
          :dateils="dateils"
        ></mydetails>
      </div>
    </transition>
  </div>
</template>

<script>
export default {
  name: "generalize.vue",
  props: {
    sonList: {
      type: Array
    },
    count: {
      type: Number
    }
  },
  watch: {
    count(newlIst, olist) {
      this.pageBid3.totalCount = newlIst;
    },
    sonList(newlIst, olist) {
      if (this.$route.query.detailsID) {
        var obj = this.sonList.find(
          item => item.id == this.$route.query.detailsID
        );
        if (this.$route.query.avt == 0 && obj) {
          this.handDitle(obj);
          this.$route.query.avt = null;
        }
      }
      newlIst.forEach(item => {
        item.img = this.$store.state.baseUrl + item.img;
      });
    }
  },
  data() {
    return {
      isbusNewsDitle: false,
      pageBid3: {
        start: 1,
        limit: 10,
        totalCount: 0,
        tatalpage: 0
      },
      dateils: {}
    };
  },
  mounted() {
    if (this.count != 0) {
      this.pageBid3.totalCount = this.count;
    }
  },
  methods: {
    handDitle(item) {
      this.dateils = item;
      this.$store.commit("handBus", true);
    },
    handleSizeChange() {},
    handleCurrentChange() {
      this.$emit("handSonNav", this.$parent.activeId, val, 10);
    }
  }
};
</script>

<style lang='scss' scoped>
.title_name {
  color: #333333;
  font-size: 16px;
  margin-bottom: 23px;
}
.news_item {
  margin-bottom: 40px;
  .ditle_title_box {
    margin-bottom: 9px;
    .title_mar {
      margin-right: 12px;
    }
    .ditle_title {
      color: #808080;
      font-size: 12px;
    }
  }
}
</style>
